package com.tianquan.test;


import com.tianquan.miracle.context.ApplicationContext;
import com.tianquan.miracle.context.MiracleApplication;
import com.tianquan.test.Bean.A;
import com.tianquan.test.Bean.C;
import com.tianquan.test.Bean.D;

// 自动配置
// @MiracleFastApplication
public class MiracleDemoApplication {

    public static void main(String[] args) throws InterruptedException {
        ApplicationContext context = MiracleApplication.run(MiracleDemoApplication.class, args);

        A a = context.getBean(A.class);
        System.out.println(a);

        C c = context.getBean(C.class);
        System.out.println(c);

        D d = context.getBean(D.class);
        System.out.println(d);

        // RedissonClient redissonClient = (RedissonClient) context.getBean("redissonClient");
        // System.out.println(redissonClient);

        // 测试cglib
/*        UserServiceImpl userServiceImpl = (UserServiceImpl)context.getBean("userServiceImpl");
        User tianquan = new User(1L, "tianquan", 18);
        userServiceImpl.selectUser(tianquan);

        // 测试jdk
        OrderService orderService = (OrderService) context.getBean("orderServiceImpl");
        orderService.addUser();
        orderService.deleteUser();

        Object object = context.getBean("a");
        System.out.println("a==>" + object);*/

        // context.publishEvent(new Test(null));

        // 测试PBank
        // LoadBalancerClient loadBalancerClient = context.getBean(LoadBalancerClient.class);

        // while (true) {
        //     Thread.sleep(5000);
        //     System.out.println("=============================================");
        //     ServiceInstance userService = loadBalancerClient.choose("userService");
        //     ServiceInstance oderService = loadBalancerClient.choose("orderService");
        //     System.out.println("客户端选择userService服务 ---->" + userService);
        //     System.out.println("客户端选择oderService服务 ---->" + oderService);
        // }

    }

}
